import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_gen/gen_l10n/gyy_local.dart';
import '../../../db/entity/AttributeBean.dart';
import '../../../main.dart';
import '../../../widgets/gyy_dropdown_row.dart';
import '../../../widgets/gyy_theme.dart';
import '../../../widgets/page.dart';
import '../../../widgets/paper/menu_item.dart';

class EditBoxPage extends ScrollablePage {
  EditBoxPage({super.key});

  final List<String> comboboxItems = [
    'Item 1',
    'Item 2',
  ];
  String dropdownItem = 'Item 1';
  TextEditingController defaultController = TextEditingController();
  TextEditingController customerController = TextEditingController();
  TextEditingController dateController = TextEditingController();
  TextEditingController phoneController = TextEditingController();

  @override
  Widget buildHeader(BuildContext context) {
    return const PageHeader(title: Text('西班牙唐人街广告科技公司'));
  }

  @override
  List<Widget> buildScrollable(BuildContext context) {

    return [
      Row(
        children: [
          Expanded(
              flex: 7, child: GyyTextInput('客户/店面 名称：', customerController)),
          sizeBoxH5,
          Expanded(flex: 3, child: GyyTextInput('开单日期：', dateController))
        ],
      ),
      sizeBoxV5,
      GyyTextInput('微信/电话 信息：', phoneController),
      sizeBoxV5,
      Row(
        children: [
          SizedBox(
            child: Container(
              color: Colors.red.dark,
            ),
            width: 30,
            height: 30,
          ),
          Text('平面广告系列：',
              style: TextStyle(
                  color: Colors.red.dark,
                  fontSize: 25,
                  fontWeight: FontWeight.bold)),
          Text('请提供完整的数据资料，在设计师排版完成后务必认真核对!\n印刷产品仅对印后产品质量负责，内容错误不在质量范围内!',
              style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold)),
          spacer,
          SizedBox(
            child: GyyTextInput('客户签字：', dateController),
            width: 180,
          ),
        ],
      ),
      //菜单
      subtitle(content:  Text(GyyLocal.of(context)!.menu)),
      Row(children: const [
        Expanded(child: Text('基础款', style: headerTextStyle,)),
        Expanded(child: Text('常用款', style: headerTextStyle,)),
        Expanded(child: Text('高端款', style: headerTextStyle,)),
        Expanded(child: Text('二维码', style: headerTextStyle,)),
      ]),
      const GyyDropDownRow(),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '过敏原',
        )),
        Expanded(child: GyyTextBox(
          header: '排版费',
        )),
        Expanded(child: GyyTextBox(
          header: '数量',
        )),

        Expanded(child: GyyTextBox(
          header: '印刷费',
        )),
      ]),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '备注',
        )),
        Expanded(child: GyyTextBox(
          header: '费用小计',
        )),
        Expanded(child: GyyTextBox(
          header: '折扣',
        )),

        Expanded(child: GyyTextBox(
          header: '价格合计',
        )),
      ]),

      subtitle(content: const Text('广告单')),
      Row(children: const [
        Expanded(child: Text('基础款', style: headerTextStyle,)),
        Expanded(child: Text('常用款', style: headerTextStyle,)),
        Expanded(child: Text('高端款', style: headerTextStyle,)),
        Expanded(child: Text('二维码', style: headerTextStyle,)),
      ]),
      const GyyDropDownRow(),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '过敏原',
        )),
        Expanded(child: GyyTextBox(
          header: '排版费',
        )),
        Expanded(child: GyyTextBox(
          header: '数量',
        )),

        Expanded(child: GyyTextBox(
          header: '印刷费',
        )),
      ]),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '备注',
        )),
        Expanded(child: GyyTextBox(
          header: '费用小计',
        )),
        Expanded(child: GyyTextBox(
          header: '折扣',
        )),

        Expanded(child: GyyTextBox(
          header: '价格合计',
        )),
      ]),

      subtitle(content: const Text('大幅面')),
      Row(children: const [
        Expanded(child: Text('基础款', style: headerTextStyle,)),
        Expanded(child: Text('常用款', style: headerTextStyle,)),
        Expanded(child: Text('高端款', style: headerTextStyle,)),
        Expanded(child: Text('二维码', style: headerTextStyle,)),
      ]),
      const GyyDropDownRow(),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '过敏原',
        )),
        Expanded(child: GyyTextBox(
          header: '排版费',
        )),
        Expanded(child: GyyTextBox(
          header: '数量',
        )),

        Expanded(child: GyyTextBox(
          header: '印刷费',
        )),
      ]),
      Row(children:  const [
        Expanded(child: GyyTextBox(
          header: '备注',
        )),
        Expanded(child: GyyTextBox(
          header: '费用小计',
        )),
        Expanded(child: GyyTextBox(
          header: '折扣',
        )),

        Expanded(child: GyyTextBox(
          header: '价格合计',
        )),
      ]),

      subtitle(content: const Text('大幅面')),
      const MyMenuItem(),
      const SizedBox(height: 10,),
      FilledButton(child: Text('添加属性'), onPressed: () async{
        var customer = customerController.text;
        var phone = phoneController.text;
        debugPrint(customer  + ' - ' + phone);

        // database.attributeDao.insertOne(AttributeBean(
        //     attributeName:customer,
        //     attributeCode:phone,
        //     attributeValue:'',
        //     attributeLevel:'1',
        //     parentCode:'',
        //     searchType:0));

      }),
       SizedBox(height: 10,),
      FilledButton(child: Text('查询属性'), onPressed: () async{
        // List<Person> list =  await database.personDao.findAllPersons();
        // showMessage(context, list.length.toString());
        List<AttributeBean> list  = await database.attributeDao.findAll();
        for (var element in list) {debugPrint(element.toJson().toString());}
      }),
      SizedBox(height: 10,),
      FilledButton(child: Text('删除所有属性'), onPressed: () async{
        database.attributeDao.deleteAll();
      })

    ];
  }
}
